<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('质感系列列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>名称：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <label>尺寸分类：</label>
                            <select name="size" th:with="type=${@dict.getType('contaxx_size2')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>场景：</label>
                            <select name="scene" th:with="type=${@dict.getType('contaxx_scene')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>风格：</label>
                            <select name="style" th:with="type=${@dict.getType('contaxx_style')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:texture:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:texture:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:texture:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:texture:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<!-- 图片弹窗 -->
<div id="imageModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="imageModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="imageModalLabel">查看图片</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="关闭">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <img id="modalImage" src="" alt="图片" class="img-fluid" style="max-width: 100%; height: auto;">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    function viewImage(base64Data) {
        // 设置图片的src为base64数据
        document.getElementById('modalImage').src = base64Data;
        // 显示模态框
        $('#imageModal').modal('show');
    }

    var editFlag = [[${@permission.hasPermi('system:texture:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:texture:remove')}]];
    var sizeDatas = [[${@dict.getType('contaxx_size2')}]];
    var sceneDatas = [[${@dict.getType('contaxx_scene')}]];
    var styleDatas = [[${@dict.getType('contaxx_style')}]];
    var prefix = ctx + "system/texture";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "质感系列",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'size',
                    title: '尺寸分类',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sizeDatas, value);
                    }
                },
                {
                    field: 'scene',
                    title: '场景',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sceneDatas, value);
                    }
                },
                {
                    field: 'style',
                    title: '风格',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(styleDatas, value);
                    }
                },
                {
                    field: 'img',
                    title: '图片',
                    formatter: function(value, row, index) {
                        if (value) {
                            return '<a href="javascript:void(0);" onclick="viewImage(\'' + value + '\')">查看</a>';
                        } else {
                            return '无图片';
                        }
                    }
                },
                {
                    field: 'price',
                    title: '普通价格'
                },
                {
                    field: 'priceVip',
                    title: '会员价格'
                },
                {
                    field: 'inventory',
                    title: '库存'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
